﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markup="clr-namespace:Elysium.Markup"
                    xmlns:params="clr-namespace:Elysium.Parameters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid TextBlock.Foreground="{TemplateBinding Foreground}"
                  TextBlock.FontFamily="{TemplateBinding FontFamily}"
                  TextBlock.FontSize="{TemplateBinding FontSize}"
                  TextBlock.FontStretch="{TemplateBinding FontStretch}"
                  TextBlock.FontStyle="{TemplateBinding FontStyle}"
                  TextBlock.FontWeight="{TemplateBinding FontWeight}"
                  TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                  TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                  RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                  Margin="{TemplateBinding Padding}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"
                                      SharedSizeGroup="ContextMenuIconSizeGroup"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"
                                      SharedSizeGroup="ContextMenuShortcutSizeGroup"/>
                </Grid.ColumnDefinitions>
                <Path x:Name="CheckBullet"
                      Grid.Column="0"
                      Stroke="{markup:ThemeResource HighlightBrush}"
                      StrokeThickness="{TemplateBinding params:General.BoldThicknessValue}"
                      Stretch="Uniform"
                      Visibility="Collapsed"
                      HorizontalAlignment="Center" VerticalAlignment="Center"
                      Width="{TemplateBinding params:MenuItem.BulletSize}" Height="{TemplateBinding params:MenuItem.BulletSize}">
                    <Path.Data>
                        <GeometryGroup>
                            <LineGeometry StartPoint="0,3" EndPoint="4,8"/>
                            <LineGeometry StartPoint="4,8" EndPoint="8,0"/>
                        </GeometryGroup>
                    </Path.Data>
                </Path>
                <ContentPresenter x:Name="IconHost"
                                  Grid.Column="0"
                                  ContentSource="Icon"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Center"
                                  MinWidth="16" MinHeight="16"/>
                <ContentPresenter x:Name="HeaderHost"
                                  Grid.Column="1"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True"
                                  Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Right'}"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Center"/>
                <TextBlock Grid.Column="2"
                           Text="{TemplateBinding InputGestureText}"
                           Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Right'}"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="IconHost" Property="Visibility" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsCheckable" Value="True">
                <Setter TargetName="IconHost" Property="Visibility" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

</ResourceDictionary>